<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/fen.css"/>
    <script src="js/jquery-3.1.1.js"></script>
</head>
<body>
<div id="div1">
    <form action="${pageContext.request.contextPath}/CheckInServlet.do" method="post">
        <table class="dataintable">
            <tr>
                <td>宿舍楼号</td>
                <td>
                    <select id="lou"  onchange="selectDor()">
                        <option value="">楼号</option>
                        <c:forEach var="bbb" items="${sessionScope.build}">
                            <option value="${bbb.DOR_BUILD}">${bbb.DOR_BUILD}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
            <tr>
                <td>房间号</td>
                <td><select name="dor_id" id="fangjian">
                    <option value="">房间号</option>
                </select></td>
            </tr>
            <tr>
                <td>分数</td>
                <td><input type="text" name="qua_mark" id="qua_mark" value=""/></td>
            </tr>
            <tr>
                <td>原因</td>
                <td><textarea rows="4" cols="35" name="qua_reason" id="qua_reason"></textarea></td>
            </tr>
            <tr id="btnBox">

                <td colspan="2">
                    <button type="submit">提交</button>
                    <button type="reset">重置</button>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script>
    function selectDor(){
      var b=  $("#lou").val();
        // 先取到要传的值
        jQuery.post("${pageContext.request.contextPath}/FindDorNoServlet.do",{"dor_build":b},function (data) {
            var option="";
            jQuery.each(data,function (i, item) {
                //value
                option+="<option value='";
                //数据库SQL尽量大写,
                option+=item.DOR_ID; //加上""就变成原意字符串了,要他的值就不能加双引号
                option+="'>";
                //显示
                option+=item.DOR_NO;
                option+="</option>";
            });
            jQuery("#fangjian").html(option);

        },"JSON");
    }
</script>
</html>

